/*
 * @Author: hongbin
 * @Date: 2022-04-26 14:06:11
 * @LastEditors: hongbin
 * @LastEditTime: 2022-04-27 10:51:43
 * @Description:常用工具函数
 */

/**
 * @description: 转换为制定区间内的值
 * @param {number} percent
 * @param {[number,number]} [min,max]
 * @return {number} val
 */
export const rangeTrans = (percent: number, [min, max]: number[]) => {
  percent > 1 && (percent = 1);
  let val = min;
  const diff = max - min;
  val += diff * percent;
  return val;
};
